import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/login/Login.vue'
import Layout from '@/views/layout/Layout.vue'
// import Home from '@/views/home/Home.vue'
Vue.use(VueRouter)

const routes = [
  {
    path:'/',
    component:Layout
  },
  {
    path:'/login',
    component:Login
  },

  //首页
  {
    path:'/layout',
    component:Layout,
    redirect:"/home",
    children:[
      {
        path:"/home",
        component:()=>import('@/views/home/Home.vue')
      }
    ]
  },
  //订单
  {
    //当存在 子路由时 父路由的path属性 就没有存在的意义了==但是不能删除 vue-router 报错
    path:'/order',    //表示 这是 订单下面
    component:Layout,
    meta:{title:"订单管理"},
    redirect:"/orderList",  //强行改掉跳转链接
    children:[
        {
          path:'/orderList',
          meta:{title:"订单列表"},
          component:()=>import('@/views/order/Order.vue')
        }
    ]
  }, 
  // //商品管理
  {
    path:"/goods",  //表示以下 goods 模块
    component:Layout,
    redirect:"/goodsList",
    meta:{title:"商品管理"},
    children:[
        {
          path:'/goodsList',
          meta:{title:"商品列表"},
          component:()=>import('@/views/goods/GoodsList.vue')
        },
        {
          path:'/goodsAdd',
          meta:{title:"商品添加"},
          component:()=>import('@/views/goods/GoodsAdd.vue')
        },
        {
          path:'/goodsType',
          meta:{title:"商品分类"},
          component:()=>import('@/views/goods/GoodsType.vue')
        }
    ]
  },
  //店铺
  {
    path:'/shop',   
    component:Layout,
    redirect:"/shopInfo",
    meta:{title:"店铺管理"},
    children:[
        {
          path:'/shopInfo',
          meta:{title:"店铺管理"},
          component:()=>import('@/views/shop/Shop.vue')
        }
    ]
  },
    //账号管理
    {
      path:"/account",  //表示以下 goods 模块
      component:Layout,
      redirect:"/accountList",
      meta:{title:"账号管理"},
      children:[
          {
            path:'/accountList',
            meta:{title:"账号列表"},
            component:()=>import('@/views/account/AccountList.vue')
          },
          {
            path:'/accountAdd',
            meta:{title:"添加账号"},
            component:()=>import('@/views/account/AccountAdd.vue')
          },
          {
            path:'/accountEdit',
            meta:{title:"修改密码"},
            component:()=>import('@/views/account/AccountEdit.vue')
          }
      ]
    },
    //销售统计
    {
      path:"/count",  //表示以下 goods 模块
      component:Layout,
      redirect:"/goodsCount",
      meta:{title:"销售统计"},
      children:[
          {
            path:'/goodsCount',
            meta:{title:"商品统计"},
            component:()=>import('@/views/count/GoodsCount.vue')
          },
          {
            path:'/orderCount',
            meta:{title:"订单统计"},
            component:()=>import('@/views/count/OrderCount.vue')
          }
      ]
    },
]

const router = new VueRouter({
  routes
})

export default router